Method and system for improving client-servlet communication

ABSTRACT

A method comprises providing a one way communication path that initiates a request by a client for retrieving information from a Servlet, and sending a response by the Servlet containing at least one return code specifying success or failure of the request, and including the result of the request if available. If the Servlet identifies missing information not included in the initial request, the method includes providing a complete response to automatically open an other communication path from the Servlet via the client&#39;s web-browser to the Servlet and providing the missing information to a Servlet by making use of the response functionality of the initial request. The other communication path is supported by a further Servlet functionality component.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the right to foreign priority benefits underTitle 35, United States Code Section 119 to European Patent ApplicationNo. 05108239.4, filed Sep. 8, 2005. This application also claims thebenefit of PCT Patent Publication No. WO/2007/028670 A1, filed Jul. 26,2006 as International Patent Application No. PCT/EP2006/064658, all ofwhich is incorporated herein by reference.

FIELD OF THE PRESENT INVENTION

The present invention relates in general to Client-Server communication,and in particular to improving the Client-Servlet communication on apublic network without changing the existing communication protocol andwithout changing the client.

BACKGROUND OF THE PRESENT INVENTION

The term “Client-Server” refers to a network application architecturewhich comprises client and servers communicating with each other via acommunication protocol (e.g. HTTP).

Web refers an information space in which the items of interest, referredto as resources, are identified by global identifiers called UniformResource Identifiers(URIs). The Web is made up of three standards: TheUniform Resource Locator (URL), which specifies how each page ofinformation is given a unique “address” at which it can be found; HyperText Transfer Protocol (HTTP), which specifies how the client and serversend the information to each other, and Hyper Text Markup Language(HTML), a method of encoding the information so it can be displayed on avariety of devices.

The Web works as follow: When a client's web-browser (e.g. Microsoft'sInternet Explorer, Apple's Safari) is opened, it communicates on behalfof the client (or computer being used) using Hypertext Transfer Protocol(HTTP) and makes a web page request. Once the request is sent, theclient's web-browser computer will wait for a hypertext data stream fromthe server. When the server gets the request, it looks for the requestedfile and, if present, sends it to the client's web-browser as requested.

Servlets are programs running on a server which wait for requests comingfrom a client's web-browser and generate a response to this request (forexample as a dynamically generated Web-page).

Conventionally, Servlets perform the following functions:

-   -   A client's web-browser sends an HTTP-request to the Servlet by        invoking its URL. The client's web-browser is not necessarily        aware that it is invoking a Servlet. Invoking a Servlet is like        loading any other web page, the difference being that parameters        can be passed in the request to the Servlet and that the        response sent back by the server is not a static document but is        dynamically generated.)

The request is analyzed by the application server hosting the Servletsand is passed to the Servlet corresponding to the demanded URL.

The request is analyzed by the Servlet, eventual parameters are parsedand interpreted, and a document to return to the client's web-browser,is dynamically generated (the content of the document may depend on theeventual parameters passed by the client's web-browser in the request).

The generated document is received by the clients web-browser and isdisplayed or interpreted (in case it contains some executable scriptslike JavaScript).

Servlets have transformed the internet by providing a powerful andscalable framework for presenting dynamic content: instead of publishingstatic documents whose content has to be updated regularly, Servletsallow the client's web-browser to append parameters to HTTP —requestsand get current information based on its request. Without Servlets, itwould be impossible to create interactive Web applications where theuser interacts from his/her client's web-browser with the server.

However Servlets have one limitation: after a request is received, theyhave no way to ask the client's web-browser for missing information.

Servlets can receive, with an incoming request, a list of parametersthat can influence the action done on the server, or the informationreturned by the server. For example H you order something on theInternet, press the “submit” button will send a request containing thelist of ordered items to the server. The server will work with this list(update a database, etc.) and usually generates a confirmation pagelisting all the chosen items.

But with traditional Servlets, all parameters necessary to treat therequest on the server have to be contained in the initial request sentby the client's web-browser: if the Servlet notices during theprocessing of a request that some additional information is not providedby the client's web-browser in the initial request, there is no way tosuspend the processing, ask the client's web-browser for the missinginformation and resume the processing from the point where it wasinterrupted. This limits the application area of Servlets:

A client's web-browser has to know exactly what information the Servletneeds.

In its request, a client's web-browser may need to provide moreinformation than what is really needed by the Servlet.

Traditional Servlets cannot handle unexpected situations requiring moreinformation than provided by the client's web-browser request. It therequest does not contain all necessary information, the traditional wayto handle the problem is to stop the processing, return a Web page tothe client's web-browser which replaces the original page and displaysan error message or display a new page asking for the missinginformation and invoking the same or another Servlet with the newinformation.

This is not a very good method to handle missing information, because itmay not be simple to slop a request processing in one Servletinvocation, and continue the transaction in another Servlet invocation.Also, it may confuse the user, since quite often, the same page isdisplayed again with a small annotation informing the user about whatinformation is missing—this is problematic from a usability standpoint.

It is desirable to provide a method and system for improving theClient-Servlet communication in the World Wide Web (Web) withoutchanging the existing communication protocol and without changing theclient, more particularly, it is desirable to improve the flexibilityand interactivity of Servlets for retrieving desired information notincluded in the initial clients web browser. The present inventionaddresses such need.

SUMMARY OF THE PRESENT INVENTION

A method comprises providing a one way communication path that initiatesa request by a client for retrieving information from a Servlet, andsending a response by the Servlet containing at least one return codespecifying success or failure of the request, and including the resultof the request if available. If the Servlet identifies missinginformation not included in the initial request, the method includesproviding a complete response to automatically open an othercommunication path from the Servlet via the client's web-browser to theServlet and providing the missing information to a Servlet by making useof the response functionality of the initial request. The othercommunication path is supported by a further Servlet functionalitycomponent.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows the inventive two-way communication path of the presentinvention,

FIG. 2 A shows a Client-Server architecture with an implementation of apreferred embodiment of the inventive two-way communication path, and

FIG. 2 B shows a sequence diagram which describes communication stepsbetween client's web-browser, main Servlet and secondary Servlet in thegiven example.

FIG. 2 A shows a preferred embodiment of the present invention in aclient-server architecture.

DETAILED DESCRIPTION

The following description is presented to enable one of ordinary skillin the art to make and use the embodiment and is provided in the contextof a patent application and its requirements. Various modifications tothe implementations and the generic principles and features describedherein will be readily apparent to those skilled in the art. Thus, thepresent embodiment is not intended to be limited to the implementationsshown, but is to be accorded the widest scope consistent with theprinciples and features described herein.

The conventional one-way communication path between client and Servletremains unchanged if the initial request includes all information forretrieving the desired information. However in the case the Servletidentifies missing information not included in the initial client'sweb-browser request for retrieving the information desired, the Servletautomatically opens another communication path for providing the missinginformation to the Servlet by making use of the HTTP-responsefunctionality of said initial HTTP-request. Another communication pathis supported by a further Servlet functionality component. Thecommunication path comprises: generating a script—when executed at theclient's web-browser retrieves the missing information and invokes thefurther Servlet functionality component—by the Servlet, appending thescript to said HTTP-response indicating it as a partial response,sending the HTTP-response including the script to the client'sweb-browser, suspending execution of the initial HTTP-response by theServlet until the missing information will be available, receiving themissing information by the further Servlet functionality component,wherein the missing information is contained in a new HTTP-requestcreated by the script during its execution on the client's web-browser,providing the missing information to the Servlet, and continuingexecution of the initial HTTP-response by the Servlet using the missinginformation for retrieving the rest of the said HTTP-response andproviding the rest of the HTTP-response to the client's web-browser fordisplaying.

The reason why Servlets have the limitation described in the prior art,stems from the way the HTTP protocol and Web browsers/servers aredesigned:

HTTP is the protocol used for the communication between a client'sweb-browser and a Web-server.

Usually the HTTP-protocol allows the client's web-browser to send arequest to a web server (or an application server/a Servlet) to eithersend some information to the server (a POST request) or to get adocument from the server (a GET request).

Independent of the type of request (GET or POST) sent by the client'sweb-browser, the server should always process it and return a responsewhich contains a header containing a return code (indicating for exampleif the request could be successfully handled or not), and an eventualresult document. When the request Was successful, the client'sweb-browser usually displays the document returned by the server,replacing the original page which contained the link of the element thatproduced the request, with the response from the server.

If the request is long-running, the server can also send regularly partsof the response document before the whole document generation iscompleted. This way the user can read the beginning of the documentwithout having to wait for the whole document to be generated andtransmitted.

This is a one-way communication: the protocol only foresees acommunication initiated by the client's web-browser. The server usuallyhas no way to send a request to the client's web-browser.

To overcome this limitation, a system and method in accordance with thepresent invention uses the fact that the server can send a “partialdocument” to the client's web-browser before the whole response documentis generated, and also uses the fact that this partial document cancontain JavaScripts which can be executed by the client's web-browserbefore the whole document is completely transmitted. JavaScript is alanguage that can be embedded in HTML pages and is interpreted by theclient's web-browser.

With this invention a two-way communication between web-client andweb-server is provided which works as follows (see FIG. 1):

a client's web-browser sends an HTTP-request to a main Servlet on anapplication server. With the request it can provide some initialparameters required by the Servlet to process the request;

the main Servlet receives the request 10, extracts and

interprets the eventual parameters and starts to process the request bydoing some actions on the server side, generating a response document20;

(Up to this point, this is how prior art Servlets work), during theprocessing of the request, the main Servlet notices that someinformation is missing and that this information has to be provided bythe originator of the request 30. This information could be some missingdata that the user has to enter, some system information about theclient's web-browser itself or about the status of some other elementsin the page displayed on the client's web-browser while the request isprocessed. It has to be information which can be retrieved with orwithout user interaction by executing a JavaScript on the client'sweb-browser;

the main Servlet suspends the processing of the request and thegeneration of the response and generates a JavaScript 40 which, whenexecuted on the client's web-browser, does the following:

it retrieves (or asks the user for) the missing information;

it invokes a secondary Servlet passing the additionally retrievedinformation as a parameter and a key generated by the Servlet requestingthe information;

the main Servlet appends the JavaScript generated in the previous stepto the partially generated response document, and sends the partialresponse to the client's web-browser 50;

the main Servlet suspends its execution by waiting until it can find theinformation it is asking for in the Web session or in the shared memory,under the key it has generated before 60;

meanwhile the client's web-browser starts to display the partialdocument received from the main Servlet. If some content was alreadygenerated, it will be displayed. The JavaScripts embedded in theresponse are executed;

while executing the JavaScript embedded in the partial responsedocument, the client's web-browser retrieves the missing informationrequired by the main Servlet, encodes this information and the key,under which the information should be stored, into the URL of asecondary Servlet and sends a request to this secondary URL;

it is important to note that the result of this 2nd request—while therequest to the main Servlet is still running—should not replace thecurrent document displayed by the clients web-browser and interrupt the1st request. This can be achieved by redirecting the result of thesecond request to a separate frame, or to a specific element of the page(image, embedded frame), or by using the JavaScript API to openprogrammatically an HTTP request;

the secondary Servlet receives the request 62 containing in itsparameters a key/value pair with the information to store in the session64 (or the memory shared with the 1st Servlet). Then it returns asuccess code to the clients web-browser 65. The client's web-browser canignore the response of the secondary Servlet;

the main Servlet detects in the session (shared memory) that a value hasbeen stored for the key it had generated. It extracts this value (70;which is the information it was missing to process the request), removesit from the session/shared memory and resumes the processing of therequest;

the processing continues the rest of the response document is generated.If it appears that even more information is missing later on during theprocessing of the request, the last steps can be repeated, tosequentially ask the user for more Information 80; and

finally the request is completed and the client's web-browser receivesand displays the full response document 80.

In a preferred embodiment of the present invention, the Servlets areimplemented as Java Servlets. However the same method could be used forCGI script or any Servlet-similar programs hosted on a server and whichprovide dynamic content

in response to HTTP requests.

In a further preferred embodiment of the present invention, the scriptsare implemented as Java Scripts. However scripts (JavaScript), returnedto the client's web-browser to retrieve the missing information, couldbe in any language (Java, Visual Basic, etc. . . . ) that can beembedded in a Web page and executed on the fly by the client'sweb-browser.

In a further embodiment of the present invention, it is possible tocreate generic Servlets which receive very low level information (suchas mouse or key events) from the user, and do a complex processing ofthis information. The client's web-browser simply sends the informationabout the mouse/key events produced by the user and does not know whatthe Servlet will do when sending the request or if it will do somethingwith this information. The Servlet interprets this information, and whenit judges that an action has to be taken when a particular event occurs,it can ask the client's web-browser to provide more information aboutthe event or some other elements on the client's web-browser side and doa dynamic processing of the event dependant on the information returnedby the client's web-browser.

In another further embodiment of the present invention, Servlets areused with complex processing paths. The initial request contains enoughinformation to start the processing. During the processing, the Servletcan take different execution paths depending on the parameters, or dataretrieved by the server from backend systems (databases, etc. . . . ).If at some point a decision has to be taken by the user about how theprocessing should continue, the Servlet can ask the client's web browserto prompt the user for a decision. This decision can influence thefurther processing of the request, without interrupting the request. Theprocessing can run in a single transaction.

In a further preferred embodiment of the present invention, a secondaryServlet is additionally provided. The secondary Servlets receives thenew HTTP-request sent by the JavaScript, and stores the key value pairin the current HTTP-session object.

In a further embodiment of the present invention, instead of using asecondary Servlet, the JavaScript could send the request updating theHTTP-session to the main Servlet But in this case a second instance ofthe main Servlet would start (in parallel to the first instance which isstill generating the response to the main request and wait for themissing value).

In further embodiment of the present invention the HTTP-protocol couldbe replaced by other communication protocol that is characterized by aone way communication path initiating a request by said client'sweb-browser (3) for retrieving information from said Servlet (8), and bysending a response by said Servlet containing at least return codespecifying success or failure of said request, and including the resultof said request, if available.

In the following preferred embodiments of the present invention will bedescribed in greater detail by a way of example only making reference tothe drawing in which:

Alternatively the format of the document 13 returned by the server anddisplayed in the client's web-browser 3 need not be necessary an HTMLdocument 13. All document types that can be displayed by a client'sweb-browser 3 and that can contain script elements being interpreted bythe web-browser 3 during the rendering can be used. Example of documentsthat could be used: XML, XHTML, SVG (Scalable Vector Graphics), XUL (XMLUser Interface Language), etc. (especially all kind of XML documents).The scripts 12 embedded in the document could be written in a languageother than JavaScript. The support of JavaScript 12 in client'sweb-browser 3 (or its standardized version ECMA Script) is standard.However any kind of script or plug-in that can be embedded in thedocument 13 to be rendered by the web-browser 3, and that can beexecuted within the client's web-browser 3, to retrieve informationabout other elements in the document 13, or about the client'sweb-browser 3 or the user environments can be used. Examples could be:Visual Basic scripts, ActiveX components, Java applets, or nativeclient's web-browser 3 plug-ins. The HTTP-protocol could be replaced byother communication protocol that is characterized by a one waycommunication path initiating a request by said client's web-browser 3for retrieving information from said Servlet 8, and by sending aresponse by the Servlet 8 containing at least return code specifyingsuccess or failure of said request, and the result of said request, ifavailable.

The server side 2 is preferably an application server 4 (e.g. a J2EEserver like WebSphere, or Tomcat) with preferably a Servlet Container 6.Two Servlets—the main Servlet 8 and the secondary Servlet 10—areinstalled in this application server 4 in the preferred embodiment ofthe present invention.

Application server 4 need not be a J2EE server. Any kind of server whichis able to respond dynamically to HTTP requests coming from client'sweb-browsers 3 can be used. Examples of technologies that can be used inplace of a J2EE application server are: Microsoft .NET, or a simpleWeb-server which can execute CGI-scripts to display dynamic content. TheServlets 8, 10 and Servlet Container 6 can be replaced by similartechnologies such as ASP, PHP or CGI scripts.

A system and method in accordance with the present invention whenimplemented in its embodiment—operates as follows (see arrows in FIG. 2A):

On the client side 1 the client's web-browser 3 sends a request to themain Servlet (1). The main Servlet 8 is the Servlet which implements thelogic necessary to generate the document —13 to send to the client'sweb-browser 3 in response to the initial request. The main Servlet 8receives the request, reads eventual parameters passed with the requestand starts the generation of the document 13 to return it to client'sthe web-browser 3. The parameters passed with the request may influencethe generation of the document 13. This invention does not depend on thelogic used by the main Servlet 8 to generate the response document 13.

At some point during the generation of the response, the main Servlet 8needs additional information that has not been provided by the client'sweb-browser 3 in the request (as parameter), but that could be easilyretrieved by executing a JavaScript 12 on the client side 1 in theclient's web-browser 3.

The main Servlet 8 inserts a Javascript 12 in the document 13 it hasstarted to generate. This script 12, when executed by the client'sweb-browser 3, retrieves the missing information, sends an HTTP-requestto the secondary Servlet 10, the request containing as parameter a keygenerated by the main Servlet a (key can be any unique string generatedrandomly) and the value retrieved in the previous step.

Once the script 12 has been generated and inserted in the partialresponse, the main Servlet 8 flushes its buffer, so that the part of theresponse document 13 which has been generated until this points isimmediately transmitted to the client's web-browser (2). Thecommunication channel to the web-browser 3 is not closed. The header ofthe HTTP-response sent to the client's web-browser 3 indicates that theresponse uses a “Chunked Transfer Coding”, as defined in HTTP 1.1. Thisencoding means that the response will not come in one single piece butin a series of chunks, and that the client's web-browser 3 should waitfor new content until the server closes the connection.

Once the partially generated document 13 (the first chunk containing thebeginning of the document and the JavaScript 12 retrieving the missinginformation), is transmitted to the client's web-browser 3, the client'sweb-browser 3 starts rendering the part of the document 13 which hasbeen received so far and executes the embedded script 12, while waitingfor the rest of the document.

The execution of this script 12 retrieves the missing value and sendsanother HTTP-request to the secondary Servlet 10. This request containsas parameter the key and the value retrieved in the previous step (3).

The ability to send additional HTTP-requests to different URL while theresponse of a 1st HTTP request is being loaded is a normal behavior forweb-browsers 3. Without this capability, client's web-browsers 3 wouldnot be able for instance to display images contained in the beginning ofa long document being loaded, before the whole document is completelyloaded.

The Secondary Servlet 10 receives the HTTP-request sent by theJavaScript 12, decodes the key and value included in the parameters ofthe request, and store this key value pair in the current HTTP-sessionobject(4). The HTTP-session is an object which stores information aboutthe current session between one client 1 and the server 2. The sessionobject is passed to a Servlet each time it receives a request. If thesame clients web-browser 3 sends HTTP-requests to several Servlets 8contained in the same Servlet container 6 and in the same Webapplication, the same session object will be passed to the differentServlets 8. Servlets 8 can read write values in the session object (thevalues are stored under keys that can be used by later to retrieve thevalues). Using the HTTP-session is a common method in J2EE to passvalues between different Servlets 8.

Instead of using a secondary Servlet 10, the JavaScript 12 could sendthe request updating the HTTP-session to the main Servlet 8. But in thiscase a second instance of the main Servlet 8 would start (in parallel tothe first instance which is still generating the response to the mainrequest and wait for the missing value). The main Servlet 8 would thenneed to test when receiving the request whether the request is askingfor a document or whether the request provides additional informationthat have been requested by other instances of the Servlet treatingdocument requests (main requests). Technically this would be done bytesting the parameters passed with the request. If a specific parameteris contained in the request, the main Servlet 8 would know that itshould update the HTTP-session with a key/value pair contained in otherparameters of the request. In any other case, the main Servlet 8 shouldgenerate a response document 13. By doing this, the main Servlet 8 wouldhave 2 different logics depending on the parameters of the requests.This is exactly the same as having 2 different Servlets, each Servletimplementing a single logic.

The secondary Servlet 10 need not store the additional value passed bythe second request (the request send by the JavaScript) in theHTTP-session to make it known by the main Servlet 8. Other methods couldbe storing the value in the System properties of the Java VirtualMachine of the Servlet container 6, or using other shared memorymechanism (dependant on the technology used by the application server).Another possibility would be to make the secondary Servlet 10 store thisvalue in a file on a local disk of the server and make the main Servlet8 read the same file.

Once the requested value is found by the main Servlet 8 in the sharedmemory (in the HTTP session), the main Servlet 8 wakes up and continuethe generation of the document 13. With the missing information, thedocument 13 can now be completely generated and the rest of the document13 is transmitted to the browser (5)—during the last steps the mainServlet 8 has regular checked the content of the HTTP-session to see ifthe value was available. Each time it checked the session and the valuewas not available, it sleeps for a small amount of time and checkedagain.

Once the Servlet 8 closes the connection with the web-browser 3 (this isdone automatically when the doGet( . . . ) or doPost( . . . ) method ofthe Servlet returns), the client's web-browser knows that the wholedocument 13 has been downloaded.

A Servlet 8 could need more than one additional information from theclient's web-browser to proceed a request. The retrieval of multiplemissing information could be either done by repeating the stepsdescribed here several times during the processing of the request, or bygenerating one JavaScript 12 which retrieves and transmit all missinginformation to the secondary Servlet 10 in one HTTP-request. Thesecondary Servlet 10 must then decode several key/value pairs from thesecondary request sent by the JavaScript and update the HTTP-sessionaccordingly.

By using this method, the Servlet 8 could request additional informationfrom the client's web-browser 3, after the client's web-browser 3 hassubmitted its initial request, and during the processing of the request.The processing of the request did not have to be aborted and startedfrom the beginning again as it would have to be without this invention.

No modifications are required in the web-browser 3 and in theapplication server 4. Both main 8 and secondary 10 Servlet areseparately normal Servlets which receive an HTTP-request and return onesingle response to the originator of the request, as defined in the HTTPprotocol. The protocol is not modified. All communication between theclient's web-browser 3 and the server 2 are driven by the client'sweb-browser (as foreseen by the HTTP-protocol).

The collaboration between the two Servlets 8, 10 and the fact that aServlet can remote control the client's web-browser 3 by chunking itsresponse document and embed JavaScript commands in it makes thebi-directional communication between server and client's web-browserpossible.

In the following a simple example shows how the present inventionpractically works (see FIG. 2 B).

It is assumed that there is a main Servlet 8 which receives a requestfrom the client's web-browser 3 and generates some content in a way thatis dependant on some properties of the client's web-browser 3 which sentthe request. It is further assumed, that the main Servlet 8 needs toknow the width of the client's web-browser window that sent the request,and that this information was not included in the initial request sentto the main Servlet 8.

The width of the client's web-browser window is a property that can beeasily asked by executing the JavaScript expression “window.outerWidth”in the client's web-browser 3.

The code source of the main 8 and secondary 10 Servlets for this exampleis in the appendix at the end of this document. Note that the secondaryServlet is independent from the logic of the primary Servlet and can bereused or shared by several “main” Servlets implementing a differentlogic.

It is important to note that the result of this second request—while therequest to the main Servlet is still running—should not replace thecurrent document displayed by the client's web-browser and interrupt the1st request. This can be achieved by redirecting the result of thesecond request to a separate frame, or to a specific element of the page(image, embedded frame), or by using the JavaScript API to openprogrammatically an HTTP-request.

The secondary Servlet 10 receives the request containing in itsparameters a key/value pair with the information to store in the session(or the memory shared with the 1st Servlet). Then it returns a successcode to the web-browser 3. The web-browser 3 can ignore the response ofthe secondary Servlet 10.

The main Servlet 8 detects in the session (shared memory) that a valuehas been stored for the key it had generated. It extracts this value(which is the information it was missing to process the request),removes it from the session/shared memory and resumes the processing ofthe request.

The processing continues the rest of the response document is generated.If it appears that even more information is missing later on during theprocessing of the request, the last steps can be repeated, tosequentially ask the user for more information.

Finally the request is completed and the client's web-browser 3 receivesand displays the full response document.

FIG. 2 B describes the activities and communication that takes placebetween the client's web-browser and the 2 Servlets in this exampleaccording to present invention.

(1) The client's web-browser sends the initial request to the mainServlet 8 by sending an HTTP GET command (alternative: a POST commandcould also be used) to the server 2, requesting the URL of the mainServlet 8. This request could also contain additional parameters thatcould be used by the main Servlet 8 during the generation of theresponse document. In this example, there is no parameter.

(2) The main Servlet 8 starts the generation of the response document bywriting the beginning of the document until the point where it need themissing information (the width of the client's web-browser):

<html>  <head>  </head>  <body>

Some content produced by the Servlet before the missing value isasked<p>,

At this point, to write the rest of the document, the main Servlet 8needs the missing information. It generates a unique key, that will beused to store and find the missing value in the HTTP session, after theclient's web-browser has sent it to the secondary Servlet 10, andappends to the content generated so far a JavaScript, which, whenexecuted by the client's web-browser, will retrieve the value and sendsit with the key to the secondary Servlet 10.

Here is how the script would look like in this example:

Line 2 retrieves the width of the web-browser 3 window, the followinglines let the web-browser 3 open an HTTP-request to the secondaryServlet 10, passing as parameter the key (here the random value of thekey is key_(—)112108) and the retrieved value (here contained in thevariable “value”)

<script language=“JavaScript”> var value = window.outerWidth; varhttpReq = new XMLHttpRequest( );httpReq.open(“GET”,“SecondaryServlet?key=key_112108&value=”+value,true); httpReq.send(null); </script>

(3) The partial document (the content generated so far and the scriptretrieved the missing value) is sent to the client's web-browser 3, byflushing the buffer of the main Servlet 8. When doing this, theapplication server changes the encoding of the HTTP response to“chunked”, which indicates the client's web-browser 3 that the contentwill be transferred in several chunked pieces. FIG. 2 shows the contentof the document transferred to the clients web-browser at this point.

(4) The main Servlet 8 suspends its execution until it finds in theHTTP-session a value stored under the key it has generated in step (2).Technically it suspends its execution and checks at regular interval ifthe value is available or not. Once the value is found, it resumes itsexecution.

(5) Meanwhile the client's web-browser 3 has received the 1st chunk ofthe document sent by the main Servlet 8. It displays the displayablecontent contained in the document so far and executes the JavaScriptembedded in it. Note that the JavaScript does not affect the content ofthe document at all.

(6) When executing the JavaScript, the client's web-browser 3 retrievesthe width of its window (here 454 pixels) and sends an HTTP GET requestto the secondary Servlet 10. (Alternative, a POST request could also beused). This request contains as parameter the key generated before(key_(—)112108) and the retrieved value (454).

GET SecondaryServlet?key=key_(—)112108&value=454,

(7) The secondary Servlet 10 receives this request, decode the key andvalue out of its parameter and place in the HTTP-session the value (454)under the key (key_(—)112108). Then it immediately returns a successcode (HTTP code 200)(8),

(8) The main Servlet 8, which checked at regular interval the HTTPsession for a value stored under the key “key_(—)112108”, finds thisvalue. It removes it from the session and resume the generation of thedocument, using the value it has retrieved. (In this example, the valueis simply written in the text. In a more complex example it could beused to do a more complex layout of the document).

2nd chunked part of the document sent to the client's web-browser 3:

Finish the generation of the page: Width=454

</body> </html>

(9) The 2nd chunked part of the document is sent to the client'sweb-browser, and the main Servlet 8 closes the communication channelwith client's web-browser 3, indicating that no more content willfollow.

(10) The client's web-browser 3 displays the rest of the document.

For more detailed execution diagrams, see FIG. 1.

For the complete source code of this example see the appendix at thisend of this document.

APPENDIX Source 1: Main Servlet   import java.io.*;   importjavax.Servlet.*;   import javax.Servlet.http.*;   public classMainServlet extends HttpServlet implements Servlet { /**  * URL of thesecondary Servlet storing the requested key/value pairs  * in the HTTPsession  */ private final static String SECONDARY_SERVLET_URL =“SecondaryServlet”; /** * @see javax.Servlet.http.HttpServlet#void (javax.Servlet.http.HttpServletRequest, javax.Servlet.http.HttpServletResponse) */ public voiddoGet(HttpServletRequest req, HttpServletResponse resp)  throwsServletException, IOException {  resp.setContentType(“text/html;charset=ISO-8859-4”);  HttpSession session = req.getSession( ); PrintWriter out = resp.getWriter( );  out.println(“<html>”); out.println(“ <head>”);  out.println(“ </head>”);  out.println(“<body>”);  // Starts the generation of the response  out.println(   “Some content produced by the Servlet before the missing value isasked<p>”);  // (...)  // at some point during the processing at theanswer,  // the Servlet notlces that some information are missing  //Suspends the generation of the response.  // Asks the client'sweb-browser's to retrieve the missing value and send it to  // theserver through the secondary Servlet  // The 3rd parameter is theJavaScript expression retrieving  // the value when executed in thebrowser.  // In this example we ask the client's web-browser for thewidth of the  browser window  Object value = requestValue(req, resp,“window.outerWidth;”);  // When this method returns, the local variable“value” contains the  requested value  // Continue the generation of theresponse  // (...)  out.println(“Finish the generation of the page:Width=” + value);  out.println(“  </body>”);  out.println(“</html>”); }/**  * Generates a unique key that can be used to store the missingvalue in  the Web session  */ private String generateKey( ) {  return“key_” + System.currentTimeMillis( ); } /**  * Requests the client’sweb-browser to provide the Servlet a missing value.  * This methodsgenerates and transmit a JavaScript to be interpreted  * by the client’sweb-browser. This JavaScript retrieves the missing value  * by executinga JavaScript expression given as parameter,  * and sends a request tothe secondary Servlet that will store  * the retrieved value in the HTTPsession, to that it is accessible  * for the main Servlet  * Note thatthis method will block and suspend the main Servlet, until  * themissing value has been returned by the client’s web-browser.  *  *@param req The main HTTP request sent by the client’s web-browser tothis main Servlet  * @param resp The HTTP response used by this Servletto respond to the request  * @param JavaScriptExpression The JavaScriptexpression, which when executed  * in the client’s web-browser, returnsthe missing information needed by this Servlet  * @return The missingvalue returned by the client’s web-browser.  */ private ObjectrequestValue(  HttpServletRequest req,  HttpServletResponse resp, String JavaScriptExpression)  throws IOException {  PrintWriter out =resp.getWriter( );  HttpSession session = req.getSession( );  //Generates a unique key, that will be used to store/retrieve the  //missing value in the current HTTP session  String key = generateKey( ); // Starts the generation of a JavaScript that will retrieve  // theinformation from the client’s web-browser  out.println(“ <scriptlanguage=\“JavaScript\”>”);  // In this example the client’s web-browserwill prompt the user to enter  the missing value  out.println(“var value= “ + JavaScriptExpression + ”;”);  // once the value has been retrievedon stored on the client side  // in a JavaScript variable, transmit thisvalue to the server through  // the secondary Servlet  // Makes theclient’s web-browser open an HTTP request to the secondary Servlet,  //passing the key and value of the missing information  out.println(“varhttpReq = new XMLHttpRequest( );”);  out.println(  “httpReq.open(\“GET\”,\“”    + SECONDARY_SERVLET_URL    + “?key=”    +key    + “&value=\”+value,true);”);  out.println(“httpReq.send(null);”); out.println(“ </script>”);  // Flushes the buffer of the Servlet, sothat the JavaScript retrieving the  // missing value is transmitted andexecuted immediately by the client’s  web-browser  resp.flushBuffer( ); // Suspends the execution of the main Servlet until a value can befound  // in the HTTP session under the key defined previously  Objectvalue = session.getAttribute(key);  while (value == null) {   try {   Thread.sleep(100);   } catch (InterruptedException e) {   e.printStackTrace( );   }   value = session.getAttribute(key);  }  //Now that the value has been extracted, remove its key/value pair from // the session, to avoid memory leaks and allow the same key to bereused  // several times  session.removeAttribute(key);  return value;   }   }

Source 2: Secondary servlet  Import java.io.*;  import javax.servlet.*; import javax.servlet.http.*;  /**   * Secondary Servlet updating theHTTP session with key/value pairs.   * The key/value pairs to store arecontained in the incoming requests   * under the keys “key” and “value”.  * For example a request containing the parameters   *“mySecondaryServletURL?key=myKey&value=myvalue”   * will store the value“myValue” under the key “myKey” in the   HTTP session.   */  publicclass SecondaryServlet extends HttpServlet implements Servlet {  /**  *@see javax.servlet.http.Httpservlet#void(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)   */   public voiddoGet(HttpservletRequest req, HttpServletResponse resp)   throwsServletException, IOException {   // Extracts from the request comingfrom the browser the key/value   // pair to store in the HTTP session  String key = req.getParameter(“key”);   String value =req.getParameter(“value”);   if (key != null) {    // Store thiskey/value pair in the HTTP session    req.getSession():setAttribute(key, value);    }  }  }

1. A method comprising: providing a one way communication path thatinitiates a request by a client for retrieving information from aServlet, and sending a response by the Servlet containing at leastreturn code specifying success or failure of the request, and includingthe result of the request if available; and if the Servlet identifiesmissing information not included in the initial request, providing acomplete response to automatically open an other communication path fromthe Servlet via the client's web-browser to the Servlet and providingthe missing information to a Servlet by making use of a responsefunctionality of the initial request, wherein the other communicationpath is supported by a further Servlet functionality component.
 2. Themethod of claim 1, wherein the further Servlet functionality componentcomprises: generating a script when executed at the client's web-browserretrieves the missing information and invokes the further Servletfunctionality component by the Servlet; appending the script to theresponse indicating it as a partial response; sending the responseincluding the script to the client's web-browser. suspending executionof the initial response by the Servlet until the missing informationwill be available; receiving the missing information by the furtherServlet functionality component, wherein the missing information iscontained in a new request created by the script during its execution onthe client's web-browser; providing the missing information to Servlet,and continuing execution of the initial response by the Servlet usingthe missing information for retrieving the rest of the response andproviding the rest of the response to the client's web-browser fordisplaying.
 3. The method according to claim 1, wherein thecommunication protocol is the HTTP protocol.
 4. The method according toclaim 1, wherein the further Servlet functionality component isimplemented as separate secondary Servlet.
 5. The method according toclaim 3, wherein the secondary Servlet receives new HTTP-request sent bythe script, and stores the missing information in a shared memory usedby both Servlets.
 6. The method according to claim 3, wherein themissing information is stored by the secondary Servlet in the currentHTTP session object between the client and the server and passed to theServlet.
 7. The method according to claim 1, wherein the further Servletfunctionality component is part of the Servlet and receipt of the newHTTP request by the Servlet automatically starts a second instance ofthe Servlet, and updates the current HTTP session object with themissing information.
 8. The method according to claim 1, whereinexecution of the script by the web-browser automatically retrieves themissing information or retrieves the missing information by anadditional user input.
 9. The method according to claim 1, wherein theServlet is implemented as a Java Servlet.
 10. The method according toclaim 1, wherein the script is implemented as a Java Script.
 11. Themethod according to claim 1, wherein the script contains the missinginformation with an assigned key generated by the Servlet.